package com.gxuwz.stats.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxuwz.stats.entity.DecisionConsulting;
import com.gxuwz.stats.entity.ResearchPlatform;
import com.gxuwz.stats.entity.User;
import com.gxuwz.stats.mapper.ResearchPlatformMapper;
import com.gxuwz.stats.service.ResearchPlatformService;
import com.gxuwz.stats.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ResearchPlatformServiceImpl extends ServiceImpl<ResearchPlatformMapper, ResearchPlatform> implements ResearchPlatformService {
    @Autowired
    private UserService userService;
    @Override
    public IPage<ResearchPlatform> getResearchPlatformList(IPage<ResearchPlatform>  page, QueryWrapper<ResearchPlatform> queryWrapper){
        IPage<ResearchPlatform> resultPage = this.page(page,queryWrapper);
        for(ResearchPlatform researchPlatform : resultPage.getRecords()){
            Integer userId = researchPlatform.getUserId();
            if(userId != null){
                User user = userService.getById(userId);
                if(user != null){
                    researchPlatform.setUsername(user.getUsername());
                }
            }
        }
        return  resultPage;
    }
}
